const $t = (t: string) => t;
export const DataShortcuts = [
  {
    text: $t("今天"),
    value: new Date(),
  },
  {
    text: $t("昨天"),
    value: () => {
      const date = new Date();
      date.setTime(date.getTime() - 3600 * 1000 * 24);
      return date;
    },
  },
  {
    text: $t("一周前"),
    value: () => {
      const date = new Date();
      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
      return date;
    },
  },
];

export const genDateRangeShortcuts = () => [
  {
    text: $t("今天"),
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setTime(start.getTime());
      return [start, end];
    },
  },
  {
    text: $t("最近三天"),
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 2);
      return [start, end];
    },
  },
  {
    text: $t("最近七天"),
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
      return [start, end];
    },
  },
  {
    text: $t("这个月"),
    value: () => {
      const end = new Date();
      const currentYear = end.getFullYear();
      const currentMonth = end.getMonth();
      // 获取当前月的最后一天
      const lastDayOfMonth = new Date(
        currentYear,
        currentMonth + 1,
        0
      ).getDate();
      const start = new Date(end.getTime());
      start.setDate(1);
      end.setDate(lastDayOfMonth);
      return [start, end];
    },
  },
  {
    text: $t("上个月"),
    value: () => {
      const end = new Date();
      end.setDate(1);
      const start = new Date(end.getTime());
      start.setMonth(start.getMonth() - 1);
      end.setDate(0);
      return [start, end];
    },
  },
  {
    text: $t("接下来7天"),
    value: () => {
      const start = new Date();
      const end = new Date();
      end.setDate(start.getDate() + 6);
      return [start, end];
    },
  },
];
